﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.ViewModels
{
    public class RuleDetailViewModel : ViewModelBase
    {
        public event EventHandler ShowMoreDetailRequired;

        public event EventHandler BackRequired;


        private RuleViewModel current;

        private string problemMessage;
        private string suppressMessage;


        public IDictionary<string, RuleViewModel> Rules { get; private set; }

        public RuleViewModel Current
        {
            get
            {
                return current;
            }
            set
            {
                current = value;
                OnPropertyChanged("Current");
            }
        }

        public string ProblemMessage
        {
            get
            {
                return problemMessage;
            }
            set
            {
                problemMessage = value;
                OnPropertyChanged("ProblemMessage");
            }
        }

        public string SuppressMessage
        {
            get
            {
                return suppressMessage;
            }
            set
            {
                suppressMessage = value;
                OnPropertyChanged("SuppressMessage");
            }
        }

        public RelayCommand BackCommand { get; private set; }


        public RuleDetailViewModel()
        {
            Rules = new Dictionary<string, RuleViewModel>();
            BackCommand = new RelayCommand(o => OnBackRequired(EventArgs.Empty));
        }


        public void ShowMoreDetail()
        {
            OnShowMoreDetailRequired(EventArgs.Empty);
        }

        protected virtual void OnShowMoreDetailRequired(EventArgs e)
        {
            if (ShowMoreDetailRequired != null)
            {
                ShowMoreDetailRequired(this, e);
            }
        }

        protected virtual void OnBackRequired(EventArgs e)
        {
            if (BackRequired != null)
            {
                BackRequired(this, e);
            }
        }
    }
}
